package org.skatiger.jrove.renderer.html;

import java.io.IOException;

import org.skatiger.jrove.ResponseWriter;
import org.skatiger.jrove.ViewContext;
import org.skatiger.jrove.component.JroveAttr;
import org.skatiger.jrove.component.UIComponent;
import org.skatiger.jrove.renderer.HtmlRendererBase;

public class HtmlOutputRenderer extends HtmlRendererBase {
    @Override
    public void encodeBegin(ViewContext context, UIComponent component)
            throws IOException {
        super.encodeBegin(context, component);
        ResponseWriter writer = context.getResponseWriter();
        Object value = component.getAttributes().get(JroveAttr.VALUE_ATTR);
        boolean escape = (Boolean) component.getAttributes().get("escape");
        if (value != null) {
            if (escape) {
                writer.writeText(value, JroveAttr.VALUE_ATTR);
            } else {
                writer.write(value.toString());
            }
        }
    }
}
